<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<script type="text/javascript" src="../js/jquery-1.10.2.js"></script>
<script type="text/javascript">
	function eaChange(){
		var ea = document.myForm.c_ea.value;
		var price = document.myForm.i_price.value;
		var tot = ea * price;
		
		document.getElementById("totMoney").innerHTML = tot;
	}
	
	function fnCartInItem(){
		document.myForm.submit();
	}
	
	function fnBuyItem(){
		document.myForm.action = "myItemBuy.do";
		document.myForm.submit();
	}

</script>

<form name="myForm" action="insertCart.do" method="post">
<input type="hidden" name="i_no" value="${item.i_no }"/>
<input type="hidden" name="i_price" value="${item.i_price }"/> 
<input type="hidden" name="m_id" value="${userId}"/>
<table align="center" width="720">
		<tr height="250" border="1" align="center">
			<td width="50%">
				<img src="../upload/${item.i_image1 }" width = "200" height= "200"><br/>
			</td>
			<td valign="middle" align="left"  width="50%">
				분류 : ${item.i_category }<br/><br/>
				이름 : ${item.i_name }<br/><br/>
				재고수량 : ${item.i_ea }EA<br/><br/>
				단가 : ${item.i_price }원<br/><br/>
				구매수량 : 
				<select name="c_ea" onchange="eaChange()">
				<c:forEach var="i" begin="1" end="20">
					<option>${i }</option>
				</c:forEach>
				</select><br/><br/>
				주문금액 : <span id="totMoney"></span>원
			</td>				
		</tr>
		<tr>
			<td></td>
			<td align="left">
			<c:if test="${!empty userId }">
				<input type="image" src="../images/buy_btn.jpg" height="40" onclick="fnBuyItem()"/>
				<input type="image" src="../images/incart_btn.jpg" height="40" onclick="fnCartInItem()"/>
			</c:if>
			<c:if test="${empty userId }">
				로그인후 주문이 가능합니다.
			</c:if>
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<textarea rows="5" cols="100">${item.i_content }</textarea>
			</td>
		</tr>
	</table>
</form>